<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Messenger/classes/PhpFox_ComponentCenter.class.php, $Author:  $ */



/** Messenger Center component
 *
 * @package module.messenger
 * @version $Id: PhpFox_ComponentCenter.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *   PHPFox Team ()
 */
class PhpFox_Mod_Messenger_ComponentCenter extends BaseComponent
{
    function process()
    {
        $oSrvMessenger = $this->_oModule->getService('Messenger');
        $oSrvAccount = &App::getModuleService('Account', 'Security');
        $oEventService = &App::getModuleService('Event', 'Event');
        /* @var $oEventService PhpFox_Mod_Event_ServiceEvent */
        $oServiceSubscribe = &App::getModuleService('Account', 'Subscribe');
        /* @var $oServiceSubscribe PhpFox_Mod_Account_ServiceSubscribe */
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */

        $bEmpty = true;
        list($aAlert,$iTotalMessages) = $oSrvMessenger->checkNewMessages($oSrvAccount->getCurrentUserLogin());
        if ( $iTotalMessages > 0 )
        {
        	$bEmpty = false;
        }
        $oTpl = &$this->_oModule->getTemplate();

        $oCurrentUser = $oSecurityService->getCurrentUser();
        /*
        $iRemainDays = $oServiceSubscribe->getRemainderDaysCount($oCurrentUser);
        if ($iRemainDays > App::getParam('Mod_Account.membership_notify_days'))
        {
            $iRemainDays = 0;
        }
        */
        $aMembershipData = $oSecurityService->getMembershipData($oCurrentUser->aData['type']);

        $oTpl->assign(array(
                             'aAlert'      => $aAlert,
                             'aMembershipData' => $aMembershipData,
                             'bEmpty'      => $bEmpty,
                             // 'iRemainDays' => $iRemainDays,
                             'sUser'       => $oSrvAccount->getCurrentUserLogin(),
                             'iInvitesCnt' => $oEventService->getInvitesCount(),
                             'bCrush'      => !($oSrvAccount->checkAccess('crush', '', false)) ? false :true
        ));

        $sHtml = $oTpl->fetch('Center.html');

        return $sHtml;
    }
}
?>